<template>
  <!--查看详情-->
  <!--模态框-->
  <div>
    <el-dialog title="退货订单" :visible.sync="dialogTableVisible" width="70%">
      <el-table :data="retutn">
        <el-table-column property="returnNumber" label="退货单号"></el-table-column>
        <el-table-column  label="退货图片" width="100">
          <template slot-scope="scope">
            <el-popover trigger="hover" placement="top">
              <p><el-image
                style="width: 100px; height: 100px"
                :src="scope.row.returnImg1"
                :preview-src-list="scope.row.srcList"
                >
              </el-image></p>
              <div slot="reference" class="name-wrapper">
                <el-tag size="medium">查看图片</el-tag>
              </div>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column property="returnTime" label="退货时间"></el-table-column>
        <el-table-column property="remark" label="退货备注"></el-table-column>
        <el-table-column label="退货原因" property="returnCase.name"></el-table-column>
        <el-table-column label="商品操作">
          <template slot-scope="scope">
            <el-button round type="primary" plain v-if="scope.row.goodsState==1"  round @click="updatereturnsbygoodsState(scope.row.id,2)">确认用户退货商户处</el-button>
            <el-button round type="primary" plain v-if="scope.row.goodsState==5"  round @click="updatereturnsbygoodsState(scope.row.id,6)">确认总店出库商户处</el-button>
            <el-button round type="primary" plain v-if="scope.row.goodsState==9"  round @click="updatereturnsbygoodsState(scope.row.id,6)">确认退货</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageno"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-dialog>
  </div>
</template>

<script>
    export default {
        name: "Return_to_view_details",
      data(){
          return{
            pageno: 1,
            pagesize: 5,
            total: 1,
            dialogTableVisible:false,
            retutn:[],
            retutnid:{odId:0},

          }
      },
      methods:{
        getDataReturn(row){
          this.dialogTableVisible=true;
          this.retutnid.odId=row.id;
          this.getretutn();
        },
          getretutn(){
            var params = new URLSearchParams();
            params.append("pageno", this.pageno);
            params.append("pagesize", this.pagesize);
            params.append("odId",this.retutnid.odId);
            this.$axios.get("queryAllReturn.action",{params:params}).then(res=>{
              this.retutn=res.data.records;
              this.total=res.data.total;
            }).catch(error=>{
              this.$message.error(error)
            })
          },
        handleSizeChange(val) {
          //每页范围
          this.pagesize = val;
          this.getretutn();
        },
        handleCurrentChange(val) {
          //当前页
          this.pageno = val;
          this.getretutn();
        },
        updatereturnsbygoodsState(id,goodsState){
          var obj={
            id:id,
            goodsState:goodsState
          }
          this.$axios.put("updatereturns.action",obj).then(res=>{
            if (res.data.code>0){
              this.$message.success(res.data.msg);
              this.dialogTableVisible=false
              this.$parent.getordersSalesReturndata()
            }else {
              this.$message.error(res.data.msg)
            }
          }).catch(error=>{
            this.$message.error(error)
          })
        }
      }
    }
</script>

<style scoped>

</style>
